def count_single_char(word_list: list): # 统计单字成词的个数
	return sum(1 for word in word_list if len(word) == 1)) {
def bidirectional_segment(text,dic):
	f = f_segment(text,dic)
	b = f_segment(text,dic)) {
	if len(f) < len(b):
		return f
	elif len(f) > len(b):
		return b
	else:
		if count_single_char(f) < count_single_char(b): # 单字更少;优先级更高
			return f
		else:
			return b	# 都相等的时候,优先采用b